source("../../lib/som-utils.R")
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
source("../../lib/maps-utils.R")
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
mpr.set_base_path_analysis()
model <- mpr.load_model("som-320.rds.xz")
summary(model)
SOM of size 50x50 with a hexagonal topology and a bubble neighbourhood function.
The number of data layers is 1.
Distance measure(s) used: sumofsquares.
Training data included: 94881 objects.
Mean distance to the closest unit in the map: 0.006.
plot(model, type="changes")
df <- mpr.load_data("datos_mes.csv.xz")
df
summary(df)
id_estacion fecha fecha_cnt tmax
Length:94881 Length:94881 Min. : 1.000 Min. :-53.0
Class :character Class :character 1st Qu.: 4.000 1st Qu.:148.0
Mode :character Mode :character Median : 6.000 Median :198.0
Mean : 6.497 Mean :200.2
3rd Qu.: 9.000 3rd Qu.:255.0
Max. :12.000 Max. :403.0
tmin precip nevada prof_nieve
Min. :-121.00 Min. : 0.00 Min. :0.000000 Min. : 0.000
1st Qu.: 53.00 1st Qu.: 3.00 1st Qu.:0.000000 1st Qu.: 0.000
Median : 98.00 Median : 10.00 Median :0.000000 Median : 0.000
Mean : 98.86 Mean : 16.25 Mean :0.000295 Mean : 0.467
3rd Qu.: 148.00 3rd Qu.: 22.00 3rd Qu.:0.000000 3rd Qu.: 0.000
Max. : 254.00 Max. :422.00 Max. :6.000000 Max. :1834.000
longitud latitud altitud
Min. :27.82 Min. :-17.8889 Min. : 1.0
1st Qu.:38.28 1st Qu.: -5.6417 1st Qu.: 42.0
Median :40.82 Median : -3.4500 Median : 247.0
Mean :39.66 Mean : -3.4350 Mean : 418.5
3rd Qu.:42.08 3rd Qu.: 0.4914 3rd Qu.: 656.0
Max. :43.57 Max. : 4.2156 Max. :2535.0
world <- ne_countries(scale = "medium", returnclass = "sf")
spain <- subset(world, admin == "Spain")
plot(model, type="count", shape = "straight", palette.name = mpr.degrade.bleu)
Número de elementos en cada celda:
nb <- table(model$unit.classif)
print(nb)
1 2 4 6 8 10 11 12 14 16 18 20 22 23 24 25
123 188 272 287 435 408 44 70 37 392 356 158 171 39 52 54
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
40 50 24 13 24 1 35 36 34 38 29 30 21 15 22 20
42 43 44 45 46 47 48 49 50 51 52 55 57 59 62 63
26 12 14 18 14 10 4 17 5 90 67 110 75 115 39 27
65 66 68 71 73 74 75 76 78 79 80 81 82 83 84 85
30 76 76 61 70 63 45 29 38 26 31 9 64 23 26 16
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
18 15 32 19 25 18 30 20 20 16 17 9 7 10 16 71
103 105 107 108 110 111 113 114 115 117 119 121 126 127 129 130
293 48 13 116 42 43 35 24 32 68 340 25 39 34 67 13
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
15 36 31 44 39 34 32 36 22 22 19 20 30 22 24 7
147 148 149 150 151 152 154 156 157 158 163 164 170 171 173 175
24 25 13 17 65 59 88 35 45 77 37 33 31 64 57 58
176 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
55 84 68 21 35 40 30 42 42 20 41 20 35 26 23 22
193 194 195 196 197 198 199 200 201 203 204 205 206 207 209 211
15 20 20 4 28 18 7 27 55 51 43 40 32 58 57 50
215 216 217 218 222 223 224 225 227 228 230 231 233 234 236 237
67 53 55 226 39 50 31 26 73 25 59 54 48 40 50 37
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 254
27 24 31 29 21 17 17 6 33 17 16 16 35 57 51 45
255 256 257 259 261 262 263 264 265 270 272 273 275 277 278 279
35 62 63 59 36 24 46 56 63 200 21 51 78 77 15 76
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
72 30 47 57 65 36 62 41 39 30 37 36 28 29 21 14
296 297 298 299 300 301 303 304 305 306 308 310 311 312 315 316
43 22 26 4 37 32 26 31 50 15 61 30 34 49 70 91
317 318 319 321 322 324 326 327 328 329 330 331 332 333 335 336
73 84 57 85 58 42 104 31 59 40 29 42 41 61 45 38
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
38 44 32 27 13 9 1 27 34 29 39 7 33 49 25 29
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
29 29 54 13 17 46 31 27 45 41 42 84 110 42 43 60
369 370 372 374 375 378 379 380 381 383 388 389 390 391 392 393
68 229 54 46 55 112 45 62 49 61 19 2 50 30 11 40
394 395 396 397 398 399 400 401 402 403 404 405 408 409 410 411
41 40 36 37 13 39 53 24 18 22 27 41 31 43 45 70
412 413 418 422 424 426 427 428 429 431 432 434 435 436 437 438
79 70 72 238 69 86 121 63 64 44 46 49 31 24 16 18
439 440 441 442 443 445 446 447 448 449 450 451 452 453 454 455
28 28 17 43 25 23 37 17 39 35 37 12 8 22 28 7
457 458 459 460 461 462 463 464 465 466 467 469 471 474 476 477
19 27 38 50 74 54 60 72 84 72 391 206 491 102 138 61
478 479 481 483 486 487 488 490 492 494 495 496 497 498 499 500
55 78 89 63 60 39 32 18 59 29 32 34 22 26 25 37
501 506 507 508 509 510 512 513 514 515 516 520 522 523 525 526
5 32 38 44 43 76 57 62 70 86 80 118 228 93 92 72
527 531 532 534 535 536 538 539 540 541 543 544 545 546 547 548
90 32 56 65 57 59 27 57 13 62 38 24 37 23 30 21
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 567
31 17 13 42 36 33 37 17 40 59 64 44 64 64 35 48
568 569 575 577 579 581 583 584 588 589 593 594 595 596 597 598
71 42 214 131 74 65 61 64 25 34 33 45 50 36 24 51
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
30 44 33 45 34 40 16 25 55 52 38 65 33 35 45 50
615 616 618 619 620 622 623 626 628 630 632 633 635 636 637 638
50 73 59 94 200 125 181 286 72 47 140 46 35 41 52 50
640 641 642 643 645 646 647 648 649 650 651 652 653 654 655 656
37 39 22 59 49 28 55 27 30 17 8 2 25 44 46 59
657 658 659 660 661 662 663 664 665 666 667 668 672 674 678 680
40 24 22 31 60 41 36 66 51 77 55 96 80 111 153 57
685 686 687 688 690 691 692 693 695 697 698 699 700 701 702 703
62 74 48 41 33 21 24 44 42 40 29 36 28 13 11 5
704 705 706 707 708 709 710 711 712 713 714 719 721 722 723 725
28 23 31 42 41 32 42 37 43 39 43 150 49 56 46 119
726 728 729 731 732 733 734 735 736 737 739 740 741 742 744 746
131 34 112 62 71 33 56 59 28 43 38 28 54 66 52 47
747 748 749 750 751 752 753 754 755 756 757 758 759 765 766 767
44 39 36 32 27 8 17 7 19 21 18 34 20 53 61 37
768 769 771 772 773 774 775 776 777 778 781 782 783 784 785 786
27 63 131 22 76 28 165 98 81 46 57 17 28 22 41 33
787 789 790 791 792 794 796 797 798 799 800 801 802 803 805 808
44 30 27 49 41 57 48 44 28 29 25 43 11 18 12 29
809 810 811 812 813 817 818 820 821 827 828 830 831 832 833 834
27 51 62 58 62 44 21 10 39 73 102 42 28 49 56 62
835 836 838 839 840 841 843 845 846 847 848 849 850 851 852 853
39 53 33 51 33 39 48 43 34 34 37 43 39 31 22 27
854 855 856 857 859 860 864 865 866 870 872 873 874 876 877 883
24 33 44 49 15 17 66 48 58 55 66 44 274 79 51 27
884 885 886 888 889 890 891 893 895 896 897 898 899 900 901 902
33 24 32 42 34 48 64 63 71 42 34 36 27 46 55 20
903 905 907 908 910 911 912 915 916 917 919 920 925 926 927 928
28 21 30 34 38 38 38 53 41 128 40 56 120 87 77 72
929 930 931 933 934 935 937 938 939 940 942 944 945 946 947 948
88 69 63 73 62 52 36 29 47 57 65 84 31 27 27 35
949 950 951 952 953 954 956 958 959 963 964 966 967 969 972 973
34 55 56 51 21 42 40 43 53 62 56 32 48 248 127 97
974 980 981 982 984 985 986 988 989 990 992 994 995 996 997 998
86 38 31 25 19 49 13 43 44 51 56 81 23 30 41 36
999 1000 1001 1002 1003 1004 1006 1009 1010 1011 1014 1020 1025 1026 1027 1028
31 35 59 54 26 54 60 39 49 48 50 32 93 80 134 80
1029 1030 1031 1032 1033 1034 1036 1037 1039 1041 1042 1044 1045 1046 1047 1048
40 70 68 87 14 82 26 33 52 62 55 73 26 29 25 43
1049 1050 1051 1052 1053 1055 1057 1058 1060 1061 1062 1063 1065 1067 1068 1069
49 67 60 28 73 43 71 95 51 49 45 47 69 114 120 83
1070 1072 1074 1075 1084 1086 1087 1089 1090 1091 1093 1095 1096 1097 1098 1099
27 190 125 126 61 34 49 65 50 73 59 77 32 33 25 40
1100 1101 1102 1103 1105 1108 1110 1111 1112 1113 1115 1118 1119 1120 1126 1127
55 52 63 51 48 97 2 48 43 31 149 31 78 87 82 65
1128 1129 1130 1131 1132 1133 1135 1137 1138 1139 1141 1142 1144 1145 1146 1147
114 81 91 67 69 98 33 38 35 65 50 44 59 90 29 31
1148 1149 1150 1151 1152 1153 1154 1156 1157 1159 1160 1162 1163 1164 1167 1169
26 53 37 67 49 20 58 82 59 81 40 62 28 34 87 37
1170 1171 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1185 1187 1189
49 153 87 48 49 51 15 24 12 22 18 20 18 34 55 52
1191 1192 1194 1195 1196 1197 1198 1199 1200 1201 1202 1204 1207 1209 1211 1212
65 56 52 59 17 30 51 42 46 29 75 76 71 106 49 39
1213 1214 1216 1218 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1234
33 42 108 42 19 96 101 64 8 48 61 55 63 76 105 45
1236 1238 1239 1241 1243 1244 1246 1247 1248 1249 1250 1251 1252 1253 1255 1256
46 40 70 59 71 39 35 42 31 25 50 83 36 77 65 90
1258 1260 1262 1263 1264 1266 1268 1269 1271 1272 1274 1275 1276 1277 1278 1279
132 143 51 30 59 63 81 89 42 72 33 48 23 81 32 18
1280 1281 1282 1283 1286 1288 1289 1291 1294 1295 1296 1297 1298 1300 1301 1302
48 31 30 24 47 99 44 85 89 62 31 26 59 39 50 23
1303 1304 1306 1309 1311 1314 1316 1319 1322 1324 1325 1326 1327 1328 1329 1330
94 39 85 73 163 144 117 148 180 21 18 24 21 84 45 89
1331 1332 1335 1337 1338 1340 1342 1344 1346 1347 1348 1350 1351 1352 1353 1354
98 99 48 86 56 63 51 74 32 24 48 38 44 22 14 46
1355 1356 1357 1359 1360 1362 1363 1366 1368 1371 1372 1374 1375 1376 1377 1378
75 64 27 72 72 3 105 72 239 70 70 73 30 51 93 54
1379 1380 1381 1382 1384 1385 1387 1388 1390 1392 1394 1395 1397 1398 1399 1400
18 26 30 39 35 45 47 77 61 42 79 54 28 47 70 40
1401 1402 1403 1404 1405 1406 1407 1409 1410 1415 1417 1419 1421 1423 1424 1425
58 65 26 24 88 65 53 83 91 150 120 256 83 103 14 128
1426 1427 1428 1429 1430 1431 1433 1435 1436 1437 1439 1441 1444 1445 1446 1447
12 39 27 33 26 24 21 48 38 72 96 52 77 98 78 39
1449 1450 1453 1454 1455 1456 1457 1458 1460 1462 1464 1467 1471 1472 1473 1474
44 54 88 60 31 29 105 40 112 73 74 110 51 74 29 26
1475 1476 1477 1478 1479 1480 1481 1482 1484 1485 1487 1489 1490 1491 1493 1498
15 48 53 49 28 39 36 52 30 32 56 67 31 44 54 42
1499 1500 1501 1504 1505 1506 1507 1508 1510 1513 1514 1515 1516 1518 1519 1521
30 44 48 94 77 34 102 78 520 82 78 49 107 54 103 33
1522 1524 1525 1526 1527 1528 1529 1530 1531 1532 1534 1535 1536 1538 1539 1541
28 27 36 54 6 23 41 69 51 49 22 31 65 84 39 60
1542 1545 1546 1547 1548 1549 1550 1551 1556 1557 1558 1562 1563 1565 1568 1571
54 38 39 76 51 34 34 14 84 62 70 49 70 101 62 36
1572 1573 1575 1576 1577 1578 1579 1580 1581 1582 1583 1585 1586 1588 1589 1590
25 55 61 89 49 62 58 54 40 47 43 45 52 92 19 69
1591 1592 1594 1595 1597 1598 1601 1602 1603 1604 1606 1607 1609 1611 1612 1613
51 66 54 87 34 27 26 23 20 17 108 41 251 43 36 106
1616 1619 1621 1622 1623 1624 1626 1627 1628 1629 1630 1631 1632 1635 1639 1645
106 78 49 38 40 35 26 59 72 29 25 18 23 8 36 66
1646 1648 1649 1650 1651 1652 1653 1654 1659 1660 1665 1666 1667 1668 1670 1673
62 39 37 36 41 23 33 40 79 77 152 64 24 88 133 51
1674 1678 1679 1680 1681 1682 1684 1686 1687 1688 1691 1693 1694 1697 1701 1702
52 50 18 63 24 21 96 99 121 275 122 28 133 80 44 25
1703 1705 1707 1709 1710 1712 1713 1714 1716 1718 1719 1721 1722 1723 1724 1725
43 86 113 85 79 30 131 54 34 65 74 64 33 23 99 19
1726 1727 1728 1729 1730 1731 1733 1735 1739 1740 1742 1743 1745 1747 1748 1749
45 47 57 38 62 46 92 168 85 101 33 59 61 80 55 73
1750 1751 1752 1753 1755 1756 1758 1760 1762 1763 1765 1768 1770 1773 1775 1776
85 33 41 46 76 69 95 87 80 32 68 62 138 54 100 19
1777 1778 1779 1780 1781 1783 1785 1787 1789 1790 1792 1793 1795 1801 1802 1803
38 28 32 34 25 45 80 26 48 31 65 69 81 38 26 49
1805 1807 1809 1810 1812 1814 1816 1817 1818 1819 1821 1822 1823 1825 1826 1828
58 109 51 83 76 68 61 27 38 71 126 17 43 96 44 62
1829 1830 1831 1832 1834 1835 1837 1838 1839 1841 1842 1844 1846 1847 1848 1849
19 32 11 41 51 73 43 90 102 96 43 56 91 65 130 64
1850 1851 1852 1853 1855 1856 1858 1860 1862 1864 1866 1867 1868 1870 1872 1873
165 34 32 41 45 44 110 97 78 87 91 64 57 111 29 6
1874 1875 1876 1877 1878 1879 1880 1881 1882 1884 1885 1887 1889 1891 1893 1894
27 33 24 92 16 22 44 29 107 67 63 55 69 83 65 69
1896 1901 1902 1903 1905 1907 1909 1911 1913 1915 1917 1919 1921 1922 1923 1924
94 37 50 43 64 75 111 95 83 78 58 109 22 68 7 18
1925 1926 1927 1928 1929 1930 1931 1932 1934 1936 1938 1940 1942 1945 1947 1948
47 21 96 82 20 27 17 59 82 40 66 105 85 78 89 201
1950 1951 1952 1953 1954 1956 1958 1959 1960 1962 1964 1966 1967 1969 1971 1972
42 25 51 45 29 74 115 78 35 85 84 46 50 96 23 25
1973 1974 1976 1977 1978 1979 1980 1981 1982 1983 1985 1987 1988 1990 1992 1994
81 74 44 37 27 62 19 18 27 61 58 54 52 62 61 90
1995 1997 1998 2000 2001 2002 2003 2005 2007 2009 2011 2012 2013 2015 2016 2017
94 94 81 106 43 51 24 71 94 116 50 45 79 76 33 53
2018 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034
84 38 48 30 15 54 56 34 28 75 45 29 26 38 25 85
2036 2038 2039 2041 2043 2045 2046 2047 2049 2050 2051 2052 2053 2054 2056 2058
67 29 96 69 80 23 142 72 64 36 36 22 39 18 62 66
2060 2062 2064 2065 2067 2069 2071 2072 2073 2074 2075 2076 2078 2079 2080 2081
82 55 64 56 46 99 22 45 12 44 14 90 31 55 36 15
2082 2083 2084 2085 2087 2088 2089 2091 2094 2095 2096 2098 2099 2100 2101 2102
23 21 44 48 58 29 52 86 33 103 111 23 25 29 40 60
2103 2104 2106 2108 2110 2112 2113 2115 2116 2117 2118 2120 2121 2122 2123 2124
26 19 47 48 102 35 58 54 25 29 76 25 24 37 16 31
2125 2126 2127 2128 2129 2130 2131 2132 2134 2136 2137 2138 2140 2142 2143 2144
16 55 17 21 67 25 31 60 35 53 23 84 57 101 78 109
2147 2148 2150 2151 2152 2153 2154 2155 2156 2157 2159 2160 2162 2163 2165 2166
79 60 59 24 31 43 18 10 29 21 33 67 51 42 35 29
2167 2168 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183
26 59 48 41 26 14 37 46 40 60 14 22 76 20 28 20
2184 2186 2187 2188 2190 2192 2193 2196 2197 2199 2200 2201 2202 2203 2204 2206
26 68 12 67 58 82 61 63 49 56 56 34 27 34 21 34
2207 2208 2209 2211 2212 2213 2214 2215 2216 2219 2220 2221 2222 2223 2224 2225
27 16 33 49 32 40 46 24 32 3 33 38 35 14 50 31
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2237 2239 2241 2243 2244 2245
30 50 14 24 89 22 26 37 27 58 69 53 41 46 69 49
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2259 2260 2261 2262 2263
38 88 84 123 27 21 19 16 10 19 31 27 26 30 25 21
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279
35 26 27 28 31 26 13 39 39 49 28 30 24 28 41 24
2280 2281 2282 2283 2284 2286 2287 2288 2289 2291 2292 2293 2294 2295 2296 2297
18 15 32 33 12 59 4 60 56 57 46 57 51 84 81 82
2298 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318
86 21 10 14 13 14 17 11 30 12 34 9 17 15 24 16
2319 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335
19 23 54 44 24 27 28 30 28 31 22 70 35 20 15 89
2336 2337 2338 2340 2341 2342 2349 2350 2351 2352 2353 2357 2359 2360 2361 2362
5 45 39 43 38 35 105 92 102 79 68 5 18 19 13 12
2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379
16 23 17 24 39 29 26 31 19 26 53 43 24 30 16 28
2380 2381 2382 2383 2384 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396
36 18 49 29 16 3 36 37 16 33 36 47 61 83 77 106
2397 2398 2399 2401 2402 2403 2404 2405 2406 2407 2409 2410 2411 2412 2413 2414
94 101 99 82 19 59 55 50 24 15 9 19 13 19 16 13
2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430
29 17 19 14 22 15 34 20 23 57 43 30 34 33 35 24
2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2450 2451 2453 2454 2455
15 42 26 17 19 33 25 11 26 30 44 132 435 53 38 49
2456 2457 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472
37 28 15 10 24 20 47 13 21 24 35 46 53 57 17 47
2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2489 2490
26 48 25 51 22 42 21 18 10 37 39 16 14 35 24 25
2491 2492 2493 2494 2495 2496 2497 2498 2499 2500
40 45 61 78 97 118 96 89 116 97
Comprobación de nodos vacíos:
dim_model <- 50*50;
len_nb = length(nb);
empty_nodes <- dim_model != len_nb;
if (empty_nodes) {
print(paste("[Warning] Existen nodos vacíos: ", len_nb, "/", dim_model))
}
[1] "[Warning] Existen nodos vacíos: 1802 / 2500"
plot(model, type="dist.neighbours", shape = "straight")
model_colnames = c("precip", "longitud", "latitud", "altitud")
model_ncol = length(model_colnames)
plot(model, shape = "straight")
par(mfrow=c(3,4))
for (j in 1:model_ncol) {
plot(model, type="property", property=getCodes(model,1)[,j],
palette.name=mpr.coolBlueHotRed,
main=model_colnames[j],
cex=0.5, shape = "straight")
}
if (!empty_nodes) {
cor <- apply(getCodes(model,1), 2, mpr.weighted.correlation, w=nb, som=model)
print(cor)
}
Representación de cada variable en un mapa de factores:
if (!empty_nodes) {
par(mfrow=c(1,1))
plot(cor[1,], cor[2,], xlim=c(-1,1), ylim=c(-1,1), type="n")
lines(c(-1,1),c(0,0))
lines(c(0,0),c(-1,1))
text(cor[1,], cor[2,], labels=model_colnames, cex=0.75)
symbols(0,0,circles=1,inches=F,add=T)
}
Importancia de cada variable - varianza ponderada por el tamaño de la celda:
if (!empty_nodes) {
sigma2 <- sqrt(apply(getCodes(model,1),2,function(x,effectif)
{m<-sum(effectif*(x-weighted.mean(x,effectif))^2)/(sum(effectif)-1)},
effectif=nb))
print(sort(sigma2,decreasing=T))
}
if (!empty_nodes) {
hac <- mpr.hac(model, nb)
}
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=3)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=3)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=4)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=4)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=5)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=5)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=6)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=6)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) summary(df.cluster06)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=8)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=8)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
df.cluster07 <- subset(df, cluster==7)
df.cluster08 <- subset(df, cluster==8)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster07 <- select(df.cluster07, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster08 <- select(df.cluster08, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) summary(df.cluster06)
if (!empty_nodes) summary(df.cluster07)
if (!empty_nodes) summary(df.cluster08)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1], dim(df.cluster07)[1], dim(df.cluster08)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06", "cluster07", "cluster08"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.hist(df.cluster07)
if (!empty_nodes) mpr.hist(df.cluster08)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster07)
if (!empty_nodes) mpr.boxplot(df.cluster08)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
df.cluster07.grouped <- mpr.group_by_geo(df.cluster07)
df.cluster08.grouped <- mpr.group_by_geo(df.cluster08)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster07.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster08.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=10)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=10)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
df.cluster07 <- subset(df, cluster==7)
df.cluster08 <- subset(df, cluster==8)
df.cluster09 <- subset(df, cluster==9)
df.cluster10 <- subset(df, cluster==10)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster07 <- select(df.cluster07, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster08 <- select(df.cluster08, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster09 <- select(df.cluster09, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster10 <- select(df.cluster10, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) summary(df.cluster06)
if (!empty_nodes) summary(df.cluster07)
if (!empty_nodes) summary(df.cluster08)
if (!empty_nodes) summary(df.cluster09)
if (!empty_nodes) summary(df.cluster10)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1], dim(df.cluster07)[1], dim(df.cluster08)[1], dim(df.cluster09)[1], dim(df.cluster10)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06", "cluster07", "cluster08", "cluster09", "cluster10"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.hist(df.cluster07)
if (!empty_nodes) mpr.hist(df.cluster08)
if (!empty_nodes) mpr.hist(df.cluster09)
if (!empty_nodes) mpr.hist(df.cluster10)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster07)
if (!empty_nodes) mpr.boxplot(df.cluster08)
if (!empty_nodes) mpr.boxplot(df.cluster09)
if (!empty_nodes) mpr.boxplot(df.cluster10)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
df.cluster07.grouped <- mpr.group_by_geo(df.cluster07)
df.cluster08.grouped <- mpr.group_by_geo(df.cluster08)
df.cluster09.grouped <- mpr.group_by_geo(df.cluster09)
df.cluster10.grouped <- mpr.group_by_geo(df.cluster10)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster07.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster08.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster09.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster10.grouped)